<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>给你的，就不会再给别人！！</title>
	<link rel="shortcut icon" href="https://static.hdslb.com/images/favicon.ico">
	<link rel="stylesheet" href="css/demo01.css">
	<link rel="stylesheet" href="css/demo02.css">
</head>
<body>
	<div class="top">
		<div class="top-banner">
			<img src="https://s1.hdslb.com/bfs/static/passport/static/img/rl_top.35edfde.png" alt="">	
		</div>	
	</div>
	<div class="title-line"><span>注册</span></div>
	<div class="data">
		<div class="login-right margin">
			<input type="text" placeholder="昵称" id="name1"><br>
			<input type="text" placeholder="密码" id="post"><br>
			<input type="text" placeholder="再次输入密码" id="post1"><br>
			<span id="randomNum"></span><button onclick="kaixue()">获取验证码</button><br>
			<input type="text" placeholder="输入验证码" id="randomNum1"><br>
			<button class="button">注册</button>
			<div class="flooer"><a href="demo01.html">已有账号，直接登录></a></div>


			
		</div>
		
	</div>
	<script src="http://libs.baidu.com/jquery/1.11.1/jquery.js"></script>
	<script>
		function Random (min,max) {
			return Math.floor(Math.random() * (max - min +  1)) + min;
		}
		function kaixue () {
			var randomNum = document.getElementById("randomNum");
			var a = Random(1000,9999);
			randomNum.innerHTML = a;

			
		}


		$(".button").click(function(){
			var username = $.trim($("#name1").val());
			var post = $("#post").val();
			var post1 = $("#post1").val();
			var  randomNum = $("#randomNum").html();
			var randomNum1 = $("#randomNum1").val();
			if (!username || !post || ! randomNum) {
				alert("昵称和密码不能为空");
				return;
			}
			if (username.length < 6 || username.length >15 ) {
				alert("昵称的长度不能大于15或小于6");
				return;
			}
			if (post.length < 6 || post.length >15 ) {
				alert("密码的长度不能大于15或小于6");
				return;
			}
			if (post != post1) {
				alert("两次输入的密码不一致！");
				return;
			}
			if (randomNum1 != randomNum) {
				alert("验证码输入错误！");
				return;
			}
			var url = "http://39.105.222.9:8095/blog/reg_user/";
			var pase = {"username":username,"password":post};
			$.post(url,pase,function(data) {
				if (data.result != 1) {
					alert(data.message);
				}else{
					alert(data.message);
					location.href = "demo01.html";	
				}	 
			})		
		})
	</script>
	
</body>
</html>